define(["avalon",
	"./assets/vendor/oniui/mmRequest/mmRequest",
	"./assets/vendor/oniui/mmRouter/mmState",
	"./assets/vendor/oniui/cookie/avalon.cookie",
	"./utils/i18n"],function(avalon,request,state,cookie, i18n){

	/**
	 * 首页路由
	 */
	 // vmName avalon.vmodels["vmName"]
	var routers = [
	  {
	    stateName: "home",
	    vmName: "app",
	    url: "/",
	    title: i18n.gettext("home page"),
	    template: require("text!./pages/home/home.html"),
	    controller: require("./pages/home/home.js")
	  },
	   {
	    stateName: "search",
	    vmName: "search",
	    url: "/search/{keyword}",
	    title: i18n.gettext("search page"),
	    template: require("text!./pages/search/search.html"),
	    controller: require("./pages/search/search.js")
	  },
	  {
	    stateName: "videos",
	    vmName: "videos",
	    url: "/videos",
	    title: i18n.gettext("videos page"),
	    template: require("text!./pages/videos/videos.html"),
	    controller: require("./pages/videos/videos.js")
	  },
	  {
	    stateName: "videos.item",
	    vmName: "video",
	    url: "/{itemID}",
	    title: i18n.gettext("video detial page"),
	    template: require("text!./pages/videos/video/video.html"),
	    controller: require("./pages/videos/video/video.js")
	  },
	  {
	    stateName: "videos.item.seek",
	    vmName: "video",
	    url: "/{seekTime}",
	    title: i18n.gettext("video detial page"),
	    template: require("text!./pages/videos/video/video.html"),
	    controller: require("./pages/videos/video/video.js")
	  },
	
	  {
	    stateName: "lives",
	    vmName: "lives",
	    url: "/lives",
	    title: i18n.gettext("lives page"),
	    template: require("text!./pages/lives/lives.html"),
	    controller: require("./pages/lives/lives.js")
	  },
	  {
	    stateName: "lives.item",
	    vmName: "live",
	    url: "/{itemID}",
	    title: i18n.gettext("live detial page"),
	    template: require("text!./pages/lives/live/live.html"),
	    controller: require("./pages/lives/live/live.js")
	  },
	  {
	    stateName: "onlines",
	    vmName: "onlines",
	    url: "/onlines",
	    title: i18n.gettext("onlines page"),
	    template: require("text!./pages/onlines/onlines.html"),
	    controller: require("./pages/onlines/onlines.js")
	  },
	  {
	    stateName: "onlines.item",
	    vmName: "online",
	    url: "/{itemID}",
	    title: i18n.gettext("online detial page"),
	    template: require("text!./pages/onlines/online/online.html"),
	    controller: require("./pages/onlines/online/online.js")
	  },
	  {
	    stateName: "albums",
	    url: "/albums",
	    vmName: "albums",
	    title:i18n.gettext("albums page"),
	    template: require("text!./pages/albums/albums.html"),
	    controller: require("./pages/albums/albums.js")
	  },
	  {
	    stateName: "albums.item",
	    url: "/{itemID}",
	    vmName: "album",
	    title: i18n.gettext("album detial page"),
	    template: require("text!./pages/albums/album/album.html"),
	    controller: require("./pages/albums/album/album.js")
	  },
	  {
	    stateName: "albums.item.play",
	    vmName: "albumPlay",
	    url: "/play/{vid}", // only handle     /play/abc  | /play/
	    title: i18n.gettext("album detial play page"),
	    template: require("text!./pages/albums/album_play/album_play.html"),
	    controller: require("./pages/albums/album_play/album_play.js")
	  },
	  {
	    stateName: "weikes",
	    url: "/weikes",
	    vmName: "weikes",
	    title:i18n.gettext("weikes page"),
	    template: require("text!./pages/weikes/weikes.html"),
	    controller: require("./pages/weikes/weikes.js") 
	  },
	  {
	    stateName: "weikes.item",
	    url: "/{itemID}",
	    vmName: "weike",
	    title: i18n.gettext("weike detial page"),
	    template: require("text!./pages/videos/video/video.html"),
	    controller: require("./pages/videos/video/video.js")
	  }, 
	  {
	    stateName: "weikes.item.seek",
	    vmName: "weikeSeek",
	    url: "/{seekTime}",
	    title: i18n.gettext("weike detial page"),
	    template: require("text!./pages/videos/video/video.html"),
	    controller: require("./pages/videos/video/video.js")
	  },
	  {
	    stateName: "weikes.item.play",
	    vmName: "weikePlay",
	    url: "/play/{vid}", // only handle     /play/abc  | /play/
	    title: i18n.gettext("weike detial play page"),
	    template: require("text!./pages/weikes/weike_play/weike_play.html"),
	    controller: require("./pages/weikes/weike_play/weike_play.js")
	  },
	  {
	  	stateName: "notices",
	  	vmName :"notices",
	  	url:"/notices",
	  	title: i18n.gettext("notices"),
	  	template: require("text!./pages/notices/notices.html"),
	  	controller: require("./pages/notices/notices.js")
	  },
	  {
	  	stateName : "notices.item", 
	  	vmName:"notice",
	  	url:"/{itemID}",
	  	title:"notice detial page",
	  	template: require("text!./pages/notices/notice/notice.html"),
	  	controller: require("./pages/notices/notice/notice.js")
	  },
	  {
	  	stateName : "liveRegister", 
	  	vmName:"liveRegister",
	  	url:"/liveRegister",
	  	title:"liveRegister page",
	  	template: require("text!./pages/liveRegister/liveRegister.html"),
	  	controller: require("./pages/liveRegister/liveRegister.js")
	  },
	  {
	  	stateName : "liveRegister.item", 
	  	vmName:"liveRegisterItem",
	  	url:"/{itemID}",
	  	title:"liveRegister page",
	  	template: require("text!./pages/liveRegister/liveRegister.html"),
	  	controller: require("./pages/liveRegister/liveRegister.js")
	  },
	  {
	  	stateName : "myVideos", 
	  	vmName:"myVideos", 
	  	url:"/myVideos",
	  	title:"myVideos page",
	  	template: require("text!./pages/myVideos/myVideos.html"),
	  	controller: require("./pages/myVideos/myVideos.js")
	  },
	  {
	  	stateName : "myRegister", 
	  	vmName:"myRegister", 
	  	url:"/myRegister",
	  	title:"myRegister page",
	  	template: require("text!./pages/myRegister/myRegister.html"),
	  	controller: require("./pages/myRegister/myRegister.js")
	  }

	];

	
	avalon.each(routers, function(i,route){
		
	  avalon.state(route.stateName,{
	    url: route.url,
	    title: route.title,
	    vmName: route.vmName,
	    views: {
	      "": {
	        //配置模块模板和控制器
	        templateProvider: function () {
	          return new Promise(function (rs) {
	            require.ensure([], function () {
	            	rs(route.template)
	            })
	          })
	        },
	        controllerProvider: function () {
	          return new Promise(function (rs) {
	            require.ensure([], function () {
	             	rs(route.controller)
	             	
	            })
	          })
	        }
	      },
	      "header": {
	      	templateProvider: function(){
	      		return new Promise(function(rs){
	      			require.ensure([], function(){
	      				rs(require("text!./pages/header/header.html"))
	      			})
	      		})
	      	},
	      	controllerProvider: function(){
	      		return new Promise(function(rs){
	      			require.ensure([], function(){
	      				rs(require("./pages/header/header.js"))
	      			})
	      		})
	      	}
	      }


	    }
	  })
	});






	return routers;

})